package com.wuwei.service.impl;

import com.wuwei.service.SendMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;


/**
 * @description: SendMsgServiceImpl <br>
 * @date: 2021/2/17 19:47 <br>
 * @author: wuwei666 <br>
 * @version: 1.0 <br>
 */
@EnableBinding(Source.class)
public class SendMsgServiceImpl implements SendMsgService {

    @Autowired
    @Qualifier("output")
    private MessageChannel channel;

    @Override
    public String SendMsg() {
        String string = UUID.randomUUID().toString();
        channel.send(MessageBuilder.withPayload(string).build());
        System.out.println("string>>>>>>>" + string);
        return string;
    }
}
